<!DOCTYPE html>  
<html>  
<head>  
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
    <meta name="keywords" content="jquery,ui,easy,easyui,web">  
    <meta name="description" content="easyui help you build your web page easily!">  
    <title>DB_Monitor</title>  
    <link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css">  
    <link rel="stylesheet" type="text/css" href="easyui/themes/icon.css">  
    <link rel="stylesheet" type="text/css" href="easyui/demo/demo.css">  
    <script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>  
    <script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>  
</head>  
<body>  
    <h2>DB_Monitor</h2>  


    <table id="dg" title="监控服务器列表" class="easyui-datagrid" style=""  
            url="getAllServ"  
            toolbar="#toolbar"  
            rownumbers="true" fitColumns="true" singleSelect="true">  
        <thead>  
            <tr>  
           		<th field="SERVER_ID">编号</th>  
                <th field="SERVER_NAME" >服务器名</th>  
                <th field="SERVER_URL" >服务器URL</th>  
                <th field="DB_USERNAME" >数据库用户名</th> 
				<th field="DB_PASSWORD" >登录密码</th> 
				<th field="DB_DATABASE_NAME" >数据库名</th> 
				<th field="DB_TABLE_NAME" >数据库表名</th> 
				<th field="DB_COLUMN_NAME" >字段名</th> 
				<th field="DATA_IN_TIME" >标准时间</th>
				<th field="DO_MONITOR_TIME" >执行时间</th> 
            </tr>  
        </thead>  
    </table>
    
    <div id="toolbar">  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newServer()">添加</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUser()">编辑</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyUser()">删除</a>  
    </div>  
      
      
      
    <div id="dlg" class="easyui-dialog" style="width:400px;padding:10px 20px" closed="true" buttons="#dlg-buttons">  
        <div class="ftitle">监控对象服务器信息</div> 
         
        <form id="fm" method="post" novalidate>  
            <div class="fitem">  
                <label>服务器编号:</label>  
                <input name="SERVER_ID" class="easyui-validatebox" required="true">  
            </div>  
            <div class="fitem">  
                <label>服务器名字:</label>  
                <input name="SERVER_NAME" class="easyui-validatebox" required="true">  
            </div>  
            <div class="fitem">  
                <label>服务器URL:</label>  
                <input name="SERVER_URL" class="easyui-validatebox" required="true">  
            </div>  
            
            <div class="fitem">  
                <label>数据库用户名:</label>  
                <input name="DB_USERNAME" class="easyui-validatebox" required="true">  
            </div>
            <div class="fitem">  
                <label>登录密码:</label>  
                <input name="DB_PASSWORD" class="easyui-validatebox" required="true">  
            </div> 
            <div class="fitem">  
                <label>数据库名:</label>  
                <input name="DB_DATABASE_NAME" class="easyui-validatebox" required="true">  
            </div>  
            <div class="fitem">  
                <label>数据库表名:</label>  
                <input name="DB_TABLE_NAME" class="easyui-validatebox" required="true">  
            </div>
            <div class="fitem">  
                <label>字段名:</label>  
                <input name="DB_COLUMN_NAME" class="easyui-validatebox" required="true">  
            </div> 
            <div class="fitem">  
                <label>标准时间:</label>  
                <input name="DATA_IN_TIME" class="easyui-validatebox" required="true">  
            </div>
            <div class="fitem">  
                <label>执行时间:</label>  
                <input name="DO_MONITOR_TIME" class="easyui-validatebox" required="true">  
            </div>        </form>  
    </div>  
    
    
    <div id="dlg-buttons">  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveUser()">Save</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">Cancel</a>  
    </div>  
    
    
    
    
    
    
    <script type="text/javascript">
      
        var url;  
        function newServer(){  
            $('#dlg').dialog('open').dialog('setTitle','添加服务器');  
            $('#fm').form('clear');  
            url = './addSerInfo';  
        }  
        
        
        
        function editUser(){  
            var row = $('#dg').datagrid('getSelected');  
            if (row){  
                $('#dlg').dialog('open').dialog('setTitle','编辑服务器信息');  
                $('#fm').form('load',row);  
                url = 'update_user.php?id='+row.id;  
            }  
        }  
        function saveUser(){  
            $('#fm').form('submit',{  
                url: url,  
                onSubmit: function(){  
                    return $(this).form('validate');  
                },  
                success: function(result){  
                    var result = eval('('+result+')');  
                    if (result.errorMsg){  
                        $.messager.show({  
                            title: 'Error',  
                            msg: result.errorMsg  
                        });  
                    } else {  
                        $('#dlg').dialog('close');      // close the dialog  
                        $('#dg').datagrid('reload');    // reload the user data  
                    }  
                }  
            });  
        }  
        function destroyUser(){  
            var row = $('#dg').datagrid('getSelected');  
            if (row){  
                $.messager.confirm('Confirm','Are you sure you want to destroy this user?',function(r){  
                    if (r){  
                        $.post('destroy_user.php',{id:row.id},function(result){  
                            if (result.success){  
                                $('#dg').datagrid('reload');    // reload the user data  
                            } else {  
                                $.messager.show({   // show error message  
                                    title: 'Error',  
                                    msg: result.errorMsg  
                                });  
                            }  
                        },'json');  
                    }  
                });  
            }  
        }  
    </script>  
    
    <style type="text/css">  
        #fm{  
            margin:0;  
            padding:10px 30px;  
        }  
        .ftitle{  
            font-size:14px;  
            font-weight:bold;  
            padding:5px 0;  
            margin-bottom:10px;  
            border-bottom:1px solid #ccc;  
        }  
        .fitem{  
            margin-bottom:5px;  
        }  
        .fitem label{  
            display:inline-block;  
            width:80px;  
        }  
    </style>  
</body>  
</html>  